<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/jsp/common/head.jsp" %>

<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>用户管理页面 >> 用户添加页面</span>
    </div>
    <div class="providerAdd">
        <!-- 添加错误信息显示 -->
        <c:if test="${not empty error}">
            <div style="color: red; margin-bottom: 10px; padding: 10px; background-color: #ffe6e6; border: 1px solid #ff9999; border-radius: 5px;">
                <strong>错误信息：</strong>${error}
            </div>
        </c:if>
        
        <form id="userForm" name="userForm" method="post" action="${pageContext.request.contextPath }/jsp/user.do">
            <input type="hidden" name="method" value="add">
            <div>
                <label for="userCode">用户编码：<span style="color: red;">*</span></label>
                <input type="text" name="userCode" id="userCode" value="${user.userCode}" required>
                <!-- 放置提示信息 -->
                <font color="red"></font>
            </div>
            <div>
                <label for="userName">用户名称：<span style="color: red;">*</span></label>
                <input type="text" name="userName" id="userName" value="${user.userName}" required>
                <font color="red"></font>
            </div>
            <div>
                <label for="userPassword">用户密码：<span style="color: red;">*</span></label>
                <input type="password" name="userPassword" id="userPassword" value="${user.userPassword}" required>
                <font color="red"></font>
            </div>
            <div>
                <label for="ruserPassword">确认密码：<span style="color: red;">*</span></label>
                <input type="password" name="ruserPassword" id="ruserPassword" value="" required>
                <font color="red"></font>
            </div>
            <div>
                <label>用户性别：<span style="color: red;">*</span></label>
                <select name="gender" id="gender" required>
                    <option value="1" selected="selected">男</option>
                    <option value="2">女</option>
                </select>
            </div>
            <div>
                <label for="birthday">出生日期：<span style="color: red;">*</span></label>
                <input type="text" Class="Wdate" id="birthday" name="birthday"
                       readonly="readonly" onclick="WdatePicker();" 
                       value="${user.birthday != null ? user.birthday : ''}" required>
                <font color="red"></font>
            </div>
            <div>
                <label for="phone">用户电话：<span style="color: red;">*</span></label>
                <input type="text" name="phone" id="phone" value="${user.phone}" required>
                <font color="red"></font>
            </div>
            <div>
                <label for="address">用户地址：</label>
                <input name="address" id="address" value="${user.address}">
            </div>
            <div>
                <label>用户角色：<span style="color: red;">*</span></label>
                <!-- 角色选项将由JavaScript动态加载 -->
                <select name="userRole" id="userRole" required data-selected="${user.userRole}">
                    <option value="0" ${user.userRole == 0 ? 'selected="selected"' : ''}>---请选择---</option>
                </select>
                <font color="red"></font>
            </div>
            <div class="providerAddBtn">
                <input type="submit" name="add" id="add" value="保存">
                <input type="button" id="back" name="back" value="返回">
            </div>
        </form>
    </div>
</div>
</section>
<%@include file="/jsp/common/foot.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/useradd.js"></script>
